﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

namespace Pc_Vision.View_Datalayer
{
    public partial class viewCategorieEdit : System.Web.UI.Page
    {

        public void fn_Cancel(object sender, EventArgs e)
        {

            Response.Redirect("Index.aspx");
        }

        public void fn_EditCategorie(object sender, EventArgs e)
        {
            DAOFactorys.DAOcategorie dc = new DAOFactorys.DAOcategorie();
            Model.Categorie c = new Model.Categorie();
            c.categorieName = tbCategorieName.Text;
            c.categorieDescription = tbCategorieDescription.Text;
            c.id = tbCategorieId.Text;

            dc.UpdateCategorie(c);


        }

        public void fn_SearchCategorie(object sender, EventArgs e)
        {
            DAOFactorys.DAOcategorie daoCategorie = new DAOFactorys.DAOcategorie();
            ArrayList arr = daoCategorie.GetAllCategories();
            string searchval = tbCategorieName.Text;
            foreach (Model.Categorie obj in arr)
            {
                if (obj.categorieName == searchval)
                {
                    tbCategorieDescription.Text = obj.categorieDescription;
                    tbCategorieId.Text = obj.id;

                }
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}